﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp
{
    public partial class Form19 : Form
    {
        public Form19()
        {
            InitializeComponent();
        }
        Process calcProcess;
        /// <summary>
        /// 开启计算器进程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            calcProcess = new Process();
            calcProcess.StartInfo.FileName = @"C:\Windows\system32\calc.exe";
            calcProcess.Start();
        }
        /// <summary>
        /// 关闭计算器进程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (!calcProcess.HasExited) {
                calcProcess.CloseMainWindow();
            }
        }
    }
}
